/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 98152
 * Date: 2024-06-18
 * Time: 17:04
 */
class Money implements Cloneable{
    public double money;

    public Money(double money) {
        this.money = money;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

public class Person implements Cloneable{
    public String name;
    public int age;
    public Money m = new Money(9.9);

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", money=" + m.money +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Person tmp = (Person)super.clone();
        tmp.m = (Money)this.m.clone();//克隆money属性
        return tmp;
    }
}

